/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao;

import cn.ekuma.data.dao.ModifiedLogDAO;
import cn.ekuma.epos.db.table.I_AttributeUse;

import com.openbravo.bean.Attribute;
import com.openbravo.bean.AttributeSet;
import com.openbravo.bean.AttributeUse;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

/**
 *
 * @author Administrator
 */
public class AttributeUseDAO extends ModifiedLogDAO<AttributeUse>{

    public AttributeUseDAO(I_Session s) {
        super(s);
    }
	
    @Override
    public TableDefinition getTable() {
       return new TableDefinition(s,
                    "ATTRIBUTEUSE",
                    new Field[]{
                       new Field(I_AttributeUse.ID,Datas.STRING, Formats.STRING),
                       new Field(I_AttributeUse.ATTRIBUTESET_ID,Datas.STRING, Formats.STRING,AttributeSet.class),
                       new Field(I_AttributeUse.ATTRIBUTE_ID,Datas.STRING, Formats.STRING,Attribute.class),
                       new Field(I_AttributeUse.LINENO,Datas.INT, Formats.INT),
                       new Field(I_AttributeUse.LASTMODIFIED,Datas.TIMESTAMP, Formats.TIMESTAMP)
                     },
                    new int[]{0}
                    );
    }

    @Override
    public void writeInsertValues(DataWrite dp, AttributeUse obj) throws BasicException {
        dp.setString(1,obj.getId());
        dp.setString(2,obj.getAttributeSetID());
        dp.setString(3,obj.getAttributeID());
        dp.setInt(4,obj.getLineNo());
        dp.setTimestamp(5,obj.getLastModified());
    }

    @Override
    public Class getSuportClass() {
        return AttributeUse.class;
    }

    public AttributeUse readValues(DataRead dr,AttributeUse obj) throws BasicException {
        if(obj==null)
        	obj=new AttributeUse();
        obj.setId(dr.getString(1));
        obj.setAttributeSetID(dr.getString(2));
        obj.setAttributeID(dr.getString(3));
        obj.setLineNo(dr.getInt(4));
        obj.setLastModified(dr.getTimestamp(5));
        return obj;
    }

}
